import {Service} from "adajs";

const MAP = {
	january: {name: "一月"},
	february: {name: "二月"},
	march: {name: "三月"},
	april: {name: "四月"},
	may: {name: "五月"},
	june: {name: "六月"},
	july: {name: "七月"},
	august: {name: "八月"},
	september: {name: "九月"},
	october: {name: "十月"},
	november: {name: "十一月"},
	december: {name: "十二月"}
};

class ImageService extends Service {
	defaultData() {
		return {
			list: []
		}
	}

	onupdate(current, {list}) {
		current.list = list.map(item => {
			let _item = Object.assign({}, item);
			_item.name = item.year;
			_item.list = Reflect.ownKeys(item).filter(key => !!MAP[key]).map(key => {
				return {
					name: MAP[key].name,
					value: item[key]
				}
			});
			return _item;
		});
	}
}

export default ImageService;